package in.muton.edushare.components.tasks.electives.api;

import in.muton.edushare.EduShareSession;

import java.io.Serializable;
import java.util.List;

import org.apache.wicket.model.IModel;

import com.edushare.common.dao.ElectivePreferenceDAO;
import com.edushare.common.vo.Curricula;
import com.edushare.common.vo.Users;

public class ElectivePanelInitInfo implements Serializable {

	public static final int SUBMITTED = 10;
	public static final int PENDING = 20;

	public static final int UNIQUE = 10;
	public static final int COMMON = 20;

	public ElectivePanelInitInfo(IModel<Curricula> currModel,
			final IModel<Users> userModel, List<Integer> groupIds, int sem) {
		this.curr = currModel;
		this.multipleGroupIds = groupIds;
		this.currSemester = sem;
		type = COMMON;
		ElectivePreferenceDAO ePrefDAO = new ElectivePreferenceDAO(
				EduShareSession.get().getSessionORMInterface());
		if (ePrefDAO.isCompleted(userModel.getObject(), currModel.getObject(),
				groupIds.get(0), sem))
			status = SUBMITTED;
		else
			status = PENDING;
	}

	public ElectivePanelInitInfo(IModel<Curricula> currModel,
			final IModel<Users> userModel, Integer groupId, int sem) {
		this.curr = currModel;
		this.singleGroupId = groupId;
		this.currSemester = sem;
		type = UNIQUE;
		ElectivePreferenceDAO ePrefDAO = new ElectivePreferenceDAO(
				EduShareSession.get().getSessionORMInterface());

		if (ePrefDAO.isCompleted(userModel.getObject(), currModel.getObject(),
				groupId, sem))
			status = SUBMITTED;
		else
			status = PENDING;
	}

	public int getType() {
		return type;
	}

	public int getStatus() {
		return status;
	}

	public Integer getCurrSemester() {
		return currSemester;
	}

	public Integer getSingleGroupId() {
		return singleGroupId;
	}

	public List<Integer> getMultipleGroupIds() {
		return multipleGroupIds;
	}

	public IModel<Curricula> getCurr() {
		return curr;
	}

	private IModel<Curricula> curr;
	private Integer currSemester;

	private int type;
	private int status;

	private Integer singleGroupId;
	private List<Integer> multipleGroupIds;

	private static final long serialVersionUID = -8610558154578873333L;
}
